<jsp:useBean id="db" scope="session" class="com.jipl.Masters.DatabaseBean"/>
<jsp:setProperty name="db" property="*"/>  
<%@ page import="java.io.* , java.util.*, java.sql.*,  com.jipl.login.*"%>
<%
request.getSession(true);
String ina=session.getAttribute("ina").toString();
String group=request.getParameter("group");
String type=request.getParameter("ctype");

String get_Group_ids="select igroupid from igroup where igname='"+group+"' and itname='"+ina+"'";
ResultSet egt_gid=db.execSQL(get_Group_ids);
int get_id=0;
if (egt_gid.next()==true)
        get_id=egt_gid.getInt(1);

String getItems="select itemname from items where igroupid='"+get_id+"'";
ResultSet getIt=db.execSQL(getItems);
String item_g="";
int cvar=0;
while (getIt.next()==true)
{
item_g=getIt.getString(1);

                String check="select * from estimateitems where iname='"+item_g+"'";
                ResultSet r1=db.execSQL(check);
		
                String check1="select * from purchase where iname='"+item_g+"'";
                ResultSet r2=db.execSQL(check1);
		
                String check2="select * from allocation where itemname='"+item_g+"'";
                ResultSet r3=db.execSQL(check2);
	
                String check4="select * from workentry where itemname='"+item_g+"'";
                ResultSet r5=db.execSQL(check4);
		
                if (r1.next()==true && r2.next()==true && r3.next()==true && r5.next()==true)
                {
                cvar=1;
                }
}

if (cvar==0)
{
                String ins="update igroup set itname='"+type+"' where itname='"+ina+"' and igname='"+group+"'";
                int ss=db.updateSQL(ins);
                if (ss>0)
                        out.println("<script language='javascript'>alert('Values Inserted!...');location='editGroup1.jsp';</script>");
                else
                        out.println("<script language='javascript'>alert('Values Not Inserted!...');location='editGroup1.jsp';</script>");
}else  if(cvar>0)
{
out.println("<script language='javascript'>alert('Items on this Group are On Use SO Plz. Dont Edit!...');location='editGroup1.jsp';</script>");
}
%>